﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using DBUtility;//请先添加引用
namespace TierApplication
{
    /// <summary>
    /// 类T_OrderShip。
    /// </summary>
    public class T_OrderShip
    {
        public T_OrderShip()
        { }
        #region Model
        private string _shipid;
        private string _shipuserid;
        private DateTime? _shipdate;
        private string _shipcompany;
        private string _remark;
        private string _shipno;
        private string _invoiceno;
        /// <summary>
        /// 
        /// </summary>
        public string ShipID
        {
            set { _shipid = value; }
            get { return _shipid; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string ShipUserID
        {
            set { _shipuserid = value; }
            get { return _shipuserid; }
        }
        /// <summary>
        /// 
        /// </summary>
        public DateTime? ShipDate
        {
            set { _shipdate = value; }
            get { return _shipdate; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string ShipCompany
        {
            set { _shipcompany = value; }
            get { return _shipcompany; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string Remark
        {
            set { _remark = value; }
            get { return _remark; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string ShipNo
        {
            set { _shipno = value; }
            get { return _shipno; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string InvoiceNo
        {
            set { _invoiceno = value; }
            get { return _invoiceno; }
        }
        #endregion Model


        #region  Method

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public T_OrderShip(string ShipID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  ");
            strSql.Append("ShipID,ShipUserID,ShipDate,ShipCompany,Remark,ShipNo,InvoiceNo ");
            strSql.Append(" from T_OrderShip ");
            strSql.Append(" where ShipID='" + ShipID + "' ");
            DataSet ds = DbHelperSQL.Query(strSql.ToString());
            if (ds.Tables[0].Rows.Count > 0)
            {
                ShipID = ds.Tables[0].Rows[0]["ShipID"].ToString();
                ShipUserID = ds.Tables[0].Rows[0]["ShipUserID"].ToString();
                if (ds.Tables[0].Rows[0]["ShipDate"].ToString() != "")
                {
                    ShipDate = DateTime.Parse(ds.Tables[0].Rows[0]["ShipDate"].ToString());
                }
                ShipCompany = ds.Tables[0].Rows[0]["ShipCompany"].ToString();
                Remark = ds.Tables[0].Rows[0]["Remark"].ToString();
                ShipNo = ds.Tables[0].Rows[0]["ShipNo"].ToString();
                InvoiceNo = ds.Tables[0].Rows[0]["InvoiceNo"].ToString();
            }
        }


        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(string ShipID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from T_OrderShip where ShipID='" + ShipID + "' ");
            return DbHelperSQL.Exists(strSql.ToString());
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into [T_OrderShip](");
            strSql.Append("ShipID,ShipUserID,ShipDate,ShipCompany,Remark,ShipNo,InvoiceNo");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("'" + ShipID + "',");
            strSql.Append("'" + ShipUserID + "',");
            strSql.Append("'" + ShipDate + "',");
            strSql.Append("'" + ShipCompany + "',");
            strSql.Append("'" + Remark + "',");
            strSql.Append("'" + ShipNo + "',");
            strSql.Append("'" + InvoiceNo + "'");
            strSql.Append(")");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update T_OrderShip set ");
            strSql.Append("ShipUserID='" + ShipUserID + "',");
            strSql.Append("ShipDate='" + ShipDate + "',");
            strSql.Append("ShipCompany='" + ShipCompany + "',");
            strSql.Append("Remark='" + Remark + "',");
            strSql.Append("ShipNo='" + ShipNo + "',");
            strSql.Append("InvoiceNo='" + InvoiceNo + "'");
            strSql.Append(" where ShipID='" + ShipID + "' ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }


        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Delete(string ShipID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from T_OrderShip ");
            strSql.Append(" where ShipID='" + ShipID + "' ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public void GetModel(string ShipID)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1  ");
            strSql.Append(" ShipID,ShipUserID,ShipDate,ShipCompany,Remark,ShipNo,InvoiceNo ");
            strSql.Append(" from T_OrderShip ");
            strSql.Append(" where ShipID='" + ShipID + "' ");
            DataSet ds = DbHelperSQL.Query(strSql.ToString());
            if (ds.Tables[0].Rows.Count > 0)
            {
                ShipID = ds.Tables[0].Rows[0]["ShipID"].ToString();
                ShipUserID = ds.Tables[0].Rows[0]["ShipUserID"].ToString();
                if (ds.Tables[0].Rows[0]["ShipDate"].ToString() != "")
                {
                    ShipDate = DateTime.Parse(ds.Tables[0].Rows[0]["ShipDate"].ToString());
                }
                ShipCompany = ds.Tables[0].Rows[0]["ShipCompany"].ToString();
                Remark = ds.Tables[0].Rows[0]["Remark"].ToString();
                ShipNo = ds.Tables[0].Rows[0]["ShipNo"].ToString();
                InvoiceNo = ds.Tables[0].Rows[0]["InvoiceNo"].ToString();
            }
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * ");
            strSql.Append(" FROM T_OrderShip ");
            if (strWhere.Trim() != "")
            {

                strSql.Append(" where " + strWhere);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }

        public static DataSet GetOrderShipSetup()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * ");
            strSql.Append(" FROM c_OrderShipSetup ");
            return DbHelperSQL.Query(strSql.ToString());
        }


        
        #endregion  Method
    }
}

